<template>
  <header>
    <div class="header-menu clearfix">
      <div class="navbar-logo">
        <!-- <img src="../assets/img/logo.jpg" alt="" /> -->
        人力管理系统
      </div>
      <ul class="navbar-option">
        <el-dropdown @command="handleCommand" trigger="click">
          <span class="el-dropdown-link">
            <i class="iconfont iconshezhi1"></i>
            {{ userName }}
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item
              v-for="(item, index) in headerMenu"
              :key="index"
              :icon="item.icon"
              :command="item.command"
              >{{ item.name }}</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
      </ul>
    </div>
  </header>
</template>
<script>
export default {
  name: "headerBar",
  data() {
    return {
      isSeting: false,
      userName: "",
      headerMenu: [
        {
          icon: "el-icon-refresh-right",
          command: "b",
          name: "退出登录",
        },
      ],
    };
  },
  methods: {
    /**设置函数 */
    clickSeting() {
      this.isSeting = !this.isSeting;
    },
    hiddenMenu() {
      this.isSeting = false;
    },
    handleCommand(e) {
      if (e == "a") {
        this.$router.push("accountSetting");
      } else {
        sessionStorage.clear();
        this.$router.push("login");
      }
    },
  },
  //userType 0-平台管理员，1-公司，2-个人，3-管理方，4-审核员，5-操作员
  created() {
    if (JSON.parse(sessionStorage.getItem("login")).userType == "1") {
      this.headerMenu.unshift({
        icon: "el-icon-user",
        command: "a",
        name: "账户设置",
      });
    }
    try {
      this.userName = JSON.parse(sessionStorage.getItem("login")).userName;
    } catch (error) {}
  },
};
</script>
<style scoped>
header {
  /* box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); */
  box-shadow: 0 1px 3px 0 rgba(57, 79, 90, 0.06);
  background-color: #fff;
  min-width: 1200px;
}
.header-menu {
  height: 60px;
  padding: 0 45px 0 30px;
}
.el-dropdown-link {
  display: inline-block;
  height: 60px;
  cursor: pointer;
  line-height: 60px;
  outline: none;
  border: none;
}
.navbar-logo {
  float: left;
  height: 100%;
  min-width: 100px;
  width: 10%;
  line-height: 60px;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
  padding-right: 30px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.navbar-logo img {
  height: 60px;
  /* padding-top: 5px; */
  /* width: 110px; */
}
.navbar-option {
  float: right;
  height: 100%;
  width: 90%;
  text-align: right;
  box-sizing: border-box;
}

@media screen and (min-width: 1500px) {
  .navbar-logo {
    font-size: 18px;
  }
}

@media screen and (max-width: 1200px) {
  .navbar-logo {
    font-size: 14px;
  }
}

@media screen and (max-width: 768px) {
  .navbar-logo {
    font-size: 12px;
  }
}

</style>
